package com.ls.shiro;

import org.apache.shiro.cache.AbstractCacheManager;
import org.apache.shiro.cache.Cache;
import org.apache.shiro.cache.CacheException;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * <p></p>
 * Created by zhezhiyong@163.com on 2017/2/22.
 */
//@Component
public class ShiroRedisCacheManager extends AbstractCacheManager{

    @Resource
    private RedisTemplate<String, Object> redisTemplate;

//    public ShiroRedisCacheManager(RedisTemplate<String, Object> redisTemplate) {
//        this.redisTemplate = redisTemplate;
//    }


    @Override
    protected Cache createCache(String prefix) throws CacheException {
        return new ShiroRedisCache<String, Object>(redisTemplate, prefix);
    }
}
